package com.qdu.program.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class DateUtil {
    public static Date toDate(String time){
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        Date newTime = new Date();
        try{
            newTime = sdf.parse(time);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return  newTime;
    }

    public static String toString(Date date){
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
        return sdf.format(date);
    }
}
